package com.kylin.upms.biz;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.toolkit.IdWorker;
import com.kylin.upms.biz.email.MailController;
import io.minio.MinioClient;
import io.minio.errors.InvalidEndpointException;
import io.minio.errors.InvalidPortException;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.List;

@SpringBootApplication(exclude = {RedisAutoConfiguration.class, SecurityAutoConfiguration.class})
@MapperScan(basePackages = {"com.kylin.upms.biz.mapper"})
@EnableSwagger2
@EnableDiscoveryClient
@RefreshScope
public class SpringBootMain implements CommandLineRunner {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootMain.class,args);
    }

    @Value(value = "${urls}")
    private String urls ;
    @Override
    public void run(String... args) throws Exception {
        System.out.println("888================"+ JSON.toJSONString(urls));
    }

    @Bean
    public MinioClient minioClient() throws InvalidPortException, InvalidEndpointException {
        return new MinioClient("http://192.168.131.140:9000","AKIAIOSFODNN7EXAMPLE","wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY");
    }
    @Bean
    public RedisTemplate redisTemplate(){
        return new RedisTemplate();
    }
    @Bean
    public MailController mailController(){
        return new MailController();
    }

}
